package com.kedll.library;

import android.util.Log;

import com.kedll.library.location.entity.LocationEntity;
import com.kedll.library.location.listener.ILocationEntity;
import com.tencent.smtt.sdk.QbSdk;

import org.litepal.LitePalApplication;


/**
 * @author andytang
 * @created Jun 11, 2014 7:27:43 PM
 */
public class KBaseApplication extends LitePalApplication implements ILocationEntity {

    public static String IP;
    public static String deviceId = "";

    public static String version = "";

    public static KBaseApplication instance;

    private LocationEntity locationEntity;

    public static KBaseApplication getInstance() {
        if (instance == null) {
            instance = new KBaseApplication();
        }
        return instance;
    }

    @Override
    public LocationEntity getLocationEntity() {
        return locationEntity;
    }

    @Override
    public void setLocation(LocationEntity entity) {
        this.locationEntity = entity;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        IP = getHost();
//        ScreenAdapterTools.initToolBar(this);

        if (getResources().getBoolean(R.bool.useX5WebView)) {
            //x5内核初始化接口
            QbSdk.initX5Environment(this, new QbSdk.PreInitCallback() {
                @Override
                public void onCoreInitFinished() {

                }

                @Override
                public void onViewInitFinished(boolean b) {
                    //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                    Log.d("app", " onViewInitFinished is " + b);
                }
            });
        }

    }

    protected String getHost() {
        return null;
    }


    @Override
    public void onTerminate() {
        super.onTerminate();
    }

}
